﻿//-----------------------------------------------------------------------
// <copyright file="ScheduleHistoryHelper.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using FastNET.CleanAct.Common.Repository;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using FastNET.CleanAct.Common.Repository.Interfaces.Repositories.ManagementEngine;
using ScheduleHistory = FastNET.CleanAct.Client.ManagerEngineData.Entities.ScheduleHistory;

#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Helpers
{
    /// <summary>
    /// Static Unit Test Helper Class for ScheduleHistory Entities
    /// </summary>
    internal static class ScheduleHistoryHelper
    {
        /// <summary>
        /// Creates an IScheduleHistoryData ready to save to the database
        /// </summary>
        /// <returns>IScheduleHistoryData with unique default values</returns>
        public static IScheduleHistoryData Create()
        {
            return Create(Guid.NewGuid());
        }

        /// <summary>
        /// Creates an IScheduleHistoryData ready to save to the database
        /// </summary>
        /// <param name="scheduleID">ScheduleID to associate the item with</param>
        /// <returns>IScheduleHistoryData with unique default values</returns>
        public static IScheduleHistoryData Create(Identity scheduleID)
        {
            ScheduleHistory item = new ScheduleHistory { ScheduleID = scheduleID, StartTimeStamp = DateTime.UtcNow };

            return item;
        }

        /// <summary>
        /// Creates an IScheduleHistoryData ready pre-saved to the database
        /// </summary>
        /// <returns>IScheduleHistoryData with unique default values</returns>
        public static IScheduleHistoryData CreateDB()
        {
            return CreateDB(ScheduleHelper.CreateDB().ID);
        }

        /// <summary>
        /// Creates an IScheduleHistoryData ready pre-saved to the database
        /// </summary>
        /// <param name="scheduleID">ScheduleID to associate the character with</param>
        /// <returns>IScheduleHistoryData with unique default values</returns>
        public static IScheduleHistoryData CreateDB(Identity scheduleID)
        {
            ScheduleHistory item = (ScheduleHistory)Create(scheduleID);

            DBHelper.Provider.GetRepository<IScheduleHistoryRepository>().Save(item);

            return item;
        }
    }
}
